package com.biometric.core.authenticator.impl

import android.util.Log
import androidx.annotation.Keep
import com.biometric.core.authenticator.BiometricAuthenticator
import com.biometric.core.retriever.AppContext
import com.wei.android.lib.fingerprintidentify.Authenticator
import com.wei.android.lib.fingerprintidentify.FingerprintIdentify

/**
 * 指纹验证器，采用指纹验证解锁
 */
@Keep
class FingerprintAuthenticator : BiometricAuthenticator {
    private val TAG = "FingerAuthenticator"
    private val delegate = FingerprintIdentify(AppContext.get())

    override fun authenticate(authenticateListener: Authenticator.AuthenticateListener) {
        if (delegate.isFingerprintEnable)
            delegate.authenticate(authenticateListener)
        else {
            Log.w(TAG, "指纹未注册")
        }
    }

    override fun reAuthenticate() {
        delegate.reAuthenticate()
    }

    override fun cancelAuthenticate() {
        delegate.cancelAuthenticate()
    }
}